package sql_age;

import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapreduce.lib.db.DBWritable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class result implements Writable, DBWritable {
    private int age;
    private int count;

    public void write(DataOutput out) throws IOException {
        out.writeInt(age);
        out.writeInt(count);
    }


    public void readFields(DataInput in) throws IOException {
        this.age = in.readInt();
        this.count = in.readInt();
    }

    public void write(PreparedStatement statement) throws SQLException {
        statement.setInt(1, this.age);
        statement.setInt(2, this.count);
    }


    public void readFields(ResultSet resultSet) throws SQLException {
        this.age = resultSet.getInt(1);
        this.count = resultSet.getInt(2);
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setCount(int count) {
        this.count = count;
    }
}
